This tutorials shows how to add View in the shape of the RoundedRectangle.
You can't combine fill and stroke on the same RoundedRectangle.
Style parameter determines whether you want
● .circular classic rounded corners
● .continuous Apple’s slightly smoother alternative
Fill
struct ContentView : View {
var body : some View {
RoundedRectangle(cornerRadius: 20, style: .continuous)
.rotation(.degrees(45))
.fill(Color.green)
.frame(width: 100, height: 100)
}
}
Stroke
struct ContentView : View {
var body : some View {
RoundedRectangle(cornerRadius: 20, style: .circular)
.rotation(.degrees(45))
.stroke(Color.green, lineWidth: 2)
.frame(width: 100, height: 100)
}
}
Fill Stroke